feat: sigagg#426
Conversation
| pub type Result<T> = std::result::Result<T, SigAggError>; | ||
|
|
||
| /// Per-duty output: one aggregated [`SignedData`] per validator public key. | ||
| pub type AggSignedDataSet = HashMap<PubKey, Box<dyn SignedData>>; |
There was a problem hiding this comment.
This is the same type introduced in #430, I think after merging those two PRs we can make a shared type for this
| /// Callback invoked after a successful threshold aggregation for a duty. | ||
| pub type AggSub = Arc< | ||
| dyn Fn(&Duty, &AggSignedDataSet) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> | ||
| + Send | ||
| + Sync | ||
| + 'static, | ||
| >; | ||
|
|
||
| /// Verify callback — checks the aggregated signature against the beacon chain. | ||
| pub type VerifyFn = Arc< | ||
| dyn Fn(&PubKey, &dyn SignedData) -> Pin<Box<dyn Future<Output = Result<()>> + Send>> | ||
| + Send | ||
| + Sync | ||
| + 'static, | ||
| >; |
There was a problem hiding this comment.
I think it would be great to replace this with async_trait
There was a problem hiding this comment.
I thought about it, but what would it give us? A bit simpler definition of the callback which is not very complicated.
|
|
||
| /// Threshold BLS share index. | ||
| pub share_idx: u64, | ||
| pub share_idx: u8, |
There was a problem hiding this comment.
Any reason to change this from u64 -> u8? share_idx is 1-based and max can be 256
There was a problem hiding this comment.
This is the reason: #426 (comment)
Hmm, why is it 1-based? That breaks possibility to keep it as u8 🤔
There was a problem hiding this comment.
Or we can keep it in u8 but we need to remember to +1 every time we use it.
There was a problem hiding this comment.
It looks like this should be u64 instead of u8 to mach charon implementation:
pluto/crates/crypto/src/types.rs
Line 23 in de42a32
So instead of changing to u8 I've should change to u64 the index.
There was a problem hiding this comment.
So in Definition
https://github.com/NethermindEth/pluto/blob/main/crates/cluster/src/definition.rs#L72
/// Charon nodes in the cluster and their operators.
/// Max 256 operators.
pub operators: Vec<Operator>,
On node_idx()
/// Returns the node index for a given peer ID.
pub fn node_idx(&self, pid: &PeerId) -> Result<NodeIdx, DefinitionError> {
let peers = self.peers()?;
for (i, peer) in peers.iter().enumerate() {
if peer.id == *pid {
return Ok(NodeIdx {
peer_idx: i,
share_idx: peer.share_idx(),
});
}
}
Err(DefinitionError::PeerNotFound { peer_id: *pid })
}
That's call share_idx()
/// Returns share index of this Peer. ShareIdx is 1-indexed while peer index
/// is 0-indexed.
pub fn share_idx(&self) -> usize {
self.index.wrapping_add(1)
}
So it will overflow if you keep it as u8. Since in dkg, we map the share_idx from definition to core type, this will fail
There was a problem hiding this comment.
Also this should be appear in the test, the boundary check
| BlstImpl.threshold_aggregate(&bls_sigs) | ||
| } | ||
| .map_err(|e| { | ||
| tracing::error!(parent: &span, error = %e, "threshold aggregate failed"); |
There was a problem hiding this comment.
In the code we import debug from tracing, but here we use tracing::error, consider using only one approach around the codebase
No description provided.